<!-- 自定义配置 -->
<template>
  <div>
    <!-- <el-form-item label="视频类型">
      <avue-select v-model="main.activeObj.data.type" :dic="dicOption.sourceTypeList"></avue-select>
    </el-form-item> -->
    <el-form-item label="选择设备">
      <el-select
        value-key="label"
        v-model="main.activeOption.deviceId"
        placeholder="请选择设备"
        clearable
        filterable
        @change="getChannelList"
      >
        <el-option
          v-for="item in deviceList"
          :label="item.name"
          :key="item.id"
          :value="item.id"
        ></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="选择通道">
      <el-select
        value-key="label"
        v-model="main.activeOption.channelId"
        placeholder="请选择通道"
        clearable
        filterable
      >
        <el-option
          v-for="item in channelList"
          :label="item.name"
          :key="item.id"
          :value="item.channelId"
        ></el-option>
      </el-select>
    </el-form-item>
    <!-- <el-form-item label="视频url">
      <avue-input v-model="main.activeObj.data.value"></avue-input>
    </el-form-item> -->
    <!-- <el-form-item label="静音">
      <avue-switch v-model="main.activeOption.sourceMuted"></avue-switch>
    </el-form-item>
    <el-form-item label="自动播放">
      <avue-switch v-model="main.activeOption.sourceAutoplay"></avue-switch>
    </el-form-item>
    <el-form-item label="控制条">
      <avue-switch v-model="main.activeOption.sourceControls"></avue-switch>
    </el-form-item>
    <el-form-item label="封面地址">
      <el-input v-model="main.activeOption.sourcePoster"></el-input>
      <div style="height: 10px;width: 100%"></div>
      <el-upload class="upload-demo"
                 :on-success="onSuccess"
                 :headers="headers"
                 :show-file-list="false"
                 :action="imgUrl"
                 multiple
                 list-type="picture">
        <el-button size="small"
                   icon="el-icon-upload"
                   type="primary">上传图片</el-button>
      </el-upload>
    </el-form-item> -->
  </div>
</template>

<script>
import { encodeQueryParam } from '@/utils/utils'
import { getVideoDeviceListNoPaging, getVideoChannelListNoPaging } from "@/api/visual";
export default {
  inject: ["main"],
  data() {
    return {
      deviceList: [],
      channelList: [],
    };
  },
  created() {
    getVideoDeviceListNoPaging().then((res) => {
      if (res.status === 200) {
        this.deviceList = res.data.result;
      }
    });
  },
  methods: {
    getChannelList(){
      getVideoChannelListNoPaging(encodeQueryParam({deviceId: this.main.activeOption.deviceId})).then(res => {
        if(res.status === 200){
          this.channelList = res.data.result;
        }
      })
    },
   
    // onSuccess (res) {
    //   this.main.activeOption.sourcePoster = res.result;
    // }
  },
};
</script>

<style>
</style>
